<!DOCTYPE html>
<html>
<head>
 <title>js获取元素的外链样式</title>
 <base target="_blank"/>
 <style type="text/css">
 p {
 width: 500px;
 line-height: 30px;
 }
 </style>
 

</head>
<body>
 <p style="width:750px;">如果您点击我，弹出宽度。</p>
 <p>点击我，弹出宽度。</p>
 <p>也要点击我哦。</p>
 <div></div>
</body>
<script>
        function getstyle(obj,property){
        if(obj.currentStyle){
        return obj.currentStyle[property];
        }else if(window.getComputedStyle){
        return document.defaultView.getComputedStyle(obj,null)[property];
        //或者也可以通过window.getComputedStyle来获取样式
        }
        return null;
        }
        
        $(document).ready(function(){
        $("p").click(function(){
        alert(getstyle(this,"width"));
        });
        });
         </script>
</html>